/**
 * Framework for batch testing user profile models
 * Final project by Sergey Nepomnyachiy and Julia Polchin
 * Supervisor: Tsvi Kuflik
 *
 */
package core.generators;

import java.util.Random;

/**
 * Generator of random doubles in range Note: The range of double is always
 * [0..1]
 * 
 * @author Sergey&Julia
 * 
 */

public class RandomDoubleGenerator extends FunctionGenerator<Double> {
	private Random rnd;

	/**
	 * Constructs generator for random doubles
	 * 
	 * @param seed
	 *            seed for the pseudo-random numbers generator
	 */
	public RandomDoubleGenerator(long seed) {
		super(null);
		this.rnd = new Random(seed);

	}

	/**
	 * Implements the generating function with Random.nextDouble()
	 * 
	 * @param index
	 *            Not used
	 */
	@SuppressWarnings("boxing")
	@Override
	Double function(int index) {
		return this.rnd.nextDouble();
	}

	/**
	 * Delegate the call for generate
	 * 
	 * @param count
	 *            How many items to generate
	 * @return reference to self (this)
	 */
	public RandomDoubleGenerator init(int count) {
		this.generate(count);
		return this;
	}
}
